<?php echo $this->Html->css('admin/admin_organisations_index'); ?>
<style>
    .big_group {
        border: solid #ccc 1px;
        padding: 10px;
        box-sizing: border-box;
        box-shadow: 1px 1px 4px #ccc;
        display: block;
        height: 350px;
    }

    .groups_list {
        display: table;
        width: 100%;
    }
    .groups_list, .groups_list ul {
        list-style: none;
        margin: 0px;
        padding: 0px;
    }

    .groups_list ul {
        overflow: auto;
        height: 200px;
    }

    .groups_list ul li {
        padding: 3px;
        overflow: hidden;
    }

    .groups_list ul li:hover {
        background-color: #f9f9f9;
    }

    .groups_list ul li.selected {
        background-color: #f9f9f9;
    }

    .groups_list .category_name {
        font-weight: bold;
        padding: 4px;
        width: 70%;
        cursor: pointer;
    }

    .groups_list .group_name, .groups_list .date_name {
        padding: 4px;
        cursor: pointer;
        width: 78%;
    }

    .groups_list .editable {
        border: solid #eee 2px;
        box-shadow: inset -1px -1px 3px #f9f9f9;
        padding: 2px;
        border-radius: 4px;
        background-color: #fff;
    }

    .groups_list .disabled {
        color: #f5f5f5;
        text-shadow: 0px 1px 1px #fafafa;
    }

    .groups_list .options {
        text-align: right;
        padding: 3px;
    }

    .groups_list .options a {
        color: #0088cc;
        text-decoration: none;
        padding: 5px;
    }

    .groups_list .column {
        display: table-cell;
        min-height: 200px;
        border-right: solid #f8f8f8 1px;
    }

    /*    .groups_list .column:not(:last-child) {
            border-right: solid #f8f8f8 1px;
        }*/

    .groups_list .column header {
        border-bottom: solid #f8f8f8 1px;
        overflow: hidden;
        vertical-align: middle;
        padding: 0px 4px;
        box-sizing: border-box;
    }

    .groups_list .column header h5 {

    }

    .groups_list .column header .btn {
        margin-top: 5px;
    }

    .groups_list .options a.remove-link {
        color: red;
    }
</style>

<div class="" id="container">

    <div class="row">
        <div class='col-lg-12'>
            <div class="panel">
                <div class="panel-body">
                    <p class="alert alert-info">
                        Complete the form below to provide basic information about this organisation. This information 
                        will be used when generating reports or presenting a public profile.
                    </p>

                    <form action="<?php echo $this->Html->url(array('action' => 'general')); ?>" method ="post" id="profile-form" class="form form-horizontal">

                        <div class="col-lg-8">
                            
                            <h5 class="font-bold">Contact Information</h5>
                            
                            <div class="form-group">
                                <div class="col-lg-3 control-label" for="name">Name: </div> 
                                <div class="col-lg-9 controls">
                                    <input class="form-control input-sm" type ="text" name="Organisation[name]" id ="name" required="" value="<?php echo $organisation['Organisation']['name']; ?>" />
                                </div>
                            </div>

                            <!--<div class="form-group">
                                <div class="col-lg-3 control-label" for="name">Username: </div> 
                                <div class="col-lg-9 controls">
                                    <input class="form-control input-sm" type ="text" name="Organisation[slug]" id ="slug" title="A unique short name. Only a-z, 0-9, _, - characters allowed." pattern="[A-za-z0-9-_]+" placeholder="A unique short name for the organisation"  required="" value="<?php echo $organisation['Organisation']['slug']; ?>" maxlength="30" />
                                </div>
                            </div>-->

                            <div class="form-group"> 
                                <div class="col-lg-3 control-label" for="email">Email: </div> 
                                <div class="col-lg-9 controls">
                                    <input class="form-control input-sm" type ="email" name="Organisation[email]" id ="email" value="<?php echo $organisation['Organisation']['email']; ?>"/>
                                </div> 
                            </div>

                            <div class="form-group">
                                <div class="col-lg-3 control-label" for="phone">Phone </div> 
                                <div class="col-lg-9 controls">
                                    <input class="form-control input-sm" type ="tel" name="Organisation[phone]" pattern='[\d-\+\(\)]+' id="phone" value="<?php echo $organisation['Organisation']['phone']; ?>" />
                                </div> 
                            </div>

                            <div class="form-group">
                                <div class="col-lg-3 control-label" for="website">Website </div> 
                                <div class="col-lg-9 controls">
                                    <input class="form-control input-sm" type="url" name="Organisation[website]" id ="website" value="<?php echo $organisation['Organisation']['website']; ?>" />
                                </div> 
                            </div>

                            <div class="form-group">
                                <div class="col-lg-3 control-label" for="address">Address </div> 
                                <div class="col-lg-9 controls">
                                    <input class="form-control input-sm" type="text" name="Organisation[address]" id ="address" value="<?php echo $organisation['Organisation']['address']; ?>"/>
                                </div> 
                            </div>

                            <div class="form-group">
                                <div class="col-lg-3 control-label" for="city">City </div> 
                                <div class="col-lg-9 controls">
                                    <input class="form-control input-sm" type ="text" name="Organisation[city]" id="city" value="<?php echo $organisation['Organisation']['city']; ?>"/>
                                </div> 
                            </div>

                            <div class="form-group">
                                <div class="col-lg-3 control-label" for="state">Region / State </div> 
                                <div class="col-lg-9 controls">
                                    <input class="form-control input-sm" type="text" name="Organisation[state]" id="state" value="<?php echo $organisation['Organisation']['state']; ?>"/>
                                </div> 
                            </div>

                            <div class="form-group">
                                <div class="col-lg-3 control-label" for="state">Post Code</div> 
                                <div class="col-lg-9 controls">
                                    <input class="form-control input-sm" type="text" name="Organisation[post_code]" id="post_code" value="<?php echo $organisation['Organisation']['post_code']; ?>"/>
                                </div> 
                            </div>

                            <div class="form-group">
                                <div class="col-lg-3 control-label" for="country">Country</div> 
                                <div class="col-lg-9 controls">
                                    <select name="Organisation[country]" required="" class="select2 input-s-lg text-sm">
                                        <option value="">Select Country</option>
                                        <?php $val = isset($organisation) ? $organisation['Organisation']['country'] : 'GH'; ?>
                                        <?php echo $this->Dropdown->generateCountries($val); ?>
                                    </select>
                                    <!--<input class="form-control input-sm" type="text" name="Organisation[country]" id="country" value="<?php echo $organisation['Organisation']['country']; ?>"/>-->
                                </div> 
                            </div>
                            
                            <h5 class="font-bold m-t-lg">Public Information</h5>
                            
                            <div class="form-group">
                                <div class="col-lg-3 control-label" for="name">Public View URL: </div> 
                                <div class="col-lg-9 controls">
                                    <span class="text-muted m-t-xs" style="display: block;">
                                        <?php
                                        $org_base = "http://" . $_SERVER['HTTP_HOST'] . Configure::read('app_folder') . $organisation['Organisation']['slug'];
                                        $url = $org_base . '/organisation/public_view';
                                        echo "<a href='$url' target='_blank' class='text-info'>$org_base</a>";
                                        ?>
                                    </span>
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <div class="col-lg-3 control-label" for="name">Mission: </div> 
                                <div class="col-lg-9 controls">
                                    <input class="form-control input-sm" type="text" name="Organisation[mission]" id="state" value="<?php echo $organisation['Organisation']['mission']; ?>"/>
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <div class="col-lg-3 control-label" for="name">Short Description: </div> 
                                <div class="col-lg-9 controls">
                                    <textarea name="Organisation[short_description]" class="form-control input-sm" rows="3" maxlength="500"><?php 
                                        echo isset($organisation) ? $organisation["Organisation"]['short_description'] : ''; 
                                    ?></textarea>
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <div class="col-lg-3 control-label" for="name">Long Description: </div> 
                                <div class="col-lg-9 controls">
                                    <textarea name="Organisation[long_description]" class="form-control input-sm" rows="8"><?php 
                                        echo isset($organisation) ? $organisation["Organisation"]['long_description'] : ''; 
                                    ?></textarea>
                                </div>
                            </div>

                            <div class="col-lg-offset-3 col-lg-9 form-actions">
                                <button type="submit" class="btn btn-primary btn-sm" disabled="" id="submit-btn">
                                    <i class="fa fa-save"></i> Save Changes
                                </button>
                                <!--<button type="button" class="btn btn-danger btn-sm" id="cancel-btn"><i class="icon icon-remove"></i> Cancel</button>-->
                            </div>
                        </div>

                        <div class="col-lg-4 text-center">
                            <div id="org_logo" class="thumb-lg">
                                <?php if ($organisation['Organisation']['logo']) { ?>
                                    <img src="<?php echo $this->Html->url($organisation['Organisation']['logo']); ?>" class="img-rounded img-thumbnail" />
                                <?php } else { ?>
                                    <img src="<?php echo $this->Html->url('/img/logo_placeholder.jpg'); ?>" class="img-rounded img-thumbnail" />
                                <?php } ?>
                            </div>

                            <div class="m-t-sm text-center">
                                <!--data-extra_params_callback='member_view.image_upload_extra_param_callback'-->
                                <!---->
                                <span class="btn btn-sm btn-white fileinput-button single-file-upload-manager"
                                      data-url='<?php echo $this->Html->url(array('controller' => 'images', 'action' => 'upload_org_logo')); ?>'
                                      data-save_to='img/org_<?php echo $organisation['Organisation']['id']; ?>/account'
                                      data-max-filesize='2000000'
                                      data-filetypes='/(\.|\/)(gif|jpe?g|png)$/i'
                                      data-image_max_width = '300'
                                      data-image_max_height='300'
                                      data-number_upload_files= 1
                                      data-callback='settings.profile.image_upload_callback'
                                      >
                                    <i class="fa fa-upload"></i>
                                    <span>Change</span>
                                    <input id="fileupload" type="file" name="files[]" multiple="">
                                </span>
                                <div id="single-upload-progress" class="progress hide" style="height: 7px; margin: 10px 0px;">
                                    <div class="progress-bar progress-bar-success"></div>
                                </div>
                            </div>

                            <input type="hidden" name="Organisation[id]" value="<?php echo $organisation['Organisation']['id']; ?>" />
                        </div>
                    </form>
                </div>
            </div>
            
        </div>
    </div>
</div>

<?php echo $this->element('single_file_upload_manager'); ?>

<?php
echo $this->Html->script('plugins/jquery.friendurl/jquery.friendurl.min.js');
echo $this->Html->script('app/views/settings/general');
?>
